package com.ragdollcat.thirdaicodegenerate.tool;

import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 工具统一管理
 */
@Component
@Slf4j
public class ToolManager {


    @Resource
    private BaseTool[] baseTool;

    private final Map<String, BaseTool> toolMap = new HashMap<String, BaseTool>();


    @PostConstruct
    public void init() {
        for (BaseTool baseTool : baseTool) {
            toolMap.put(baseTool.getName(), baseTool);
        }
        log.info("当前加载了：{}",toolMap.toString());
    }


    public BaseTool getTool(String toolName) {
        return toolMap.get(toolName);
    }

    public BaseTool[] getBaseTool() {
        return baseTool;
    }
}
